﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using ReflectionStudio.Core.Events;
using System.Collections;
using System.Collections.Generic;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class TGB03
    {



        public TGB03()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGPBST();
            this.DataContext = MV;
            InitializeComponent();

        }
        /// <summary> 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "";
            }
            else
            {
                KEY = TMV.GPBLO + TMV.GPBLB + TMV.GPBPARTIE + TMV.GPBPARTIEKZ;
            }
        }

        public override void OnARTChg(string des)
        {
            base.OnARTChg(des);
        }

        public override void OnEXAUFChg(string vlaue)
        {
            if (EXAUF.Length < 8)
                return;
            PM["LO"] = LO;
            PM["LB"] = LB;
            PM["PARTIE"] = EXAUF.Substring(0, 7);
            PM["KZ"] = EXAUF.Substring(7, 1);
            SResult = TMV.CHKGB(PM);
            MergeData(SResult, true);
            if (!IsAuto)
                return;
            if (Counts > 0)
                return;

            dwData = TBMain.NewRow();
            TMV.SetUpNewRow(ref dwData);
            dwData["GPBMANDANT"] = app.Mandant;
            dwData["GPBPARTIE"] = EXAUF.Substring(0, 7);
            dwData["GPBPARTIEKZ"] = EXAUF.Substring(7, 1);
            dwData["GPBLO"] = LO;
            dwData["GPBLB"] = LB;
            TBMain.Rows.InsertAt(dwData, 0);
            TMV.InsertGPBST(dwData);
            vwMaster.View.MoveCurrentToFirst();
            base.OnEXAUFChg(vlaue);
        }

    }
}
